﻿using System;
using System.Threading.Tasks;

using MassTransit;
using MassTransit.RabbitMqTransport;
namespace Athena
{
    public abstract class DefaultPublish : IBasePublish
    {
        private Uri _publishUri;

        public Uri PublishUri {
            get {
                return _publishUri;
            }
        }

        protected ISendEndpoint SendEndpoint {
            get;
            set;
        }

        public virtual void Initialization(ISendEndpoint sendEndpoint)
        {
            SendEndpoint = sendEndpoint;
        }

        public async Task Publish<T>(T obj) where T : class
        {
            await SendEndpoint.Send(obj);
        }

        //public virtual async Task Publish(object obj, string uri)
        //{
        //    //var endpoint = await SendEndpoint.GetSendEndpoint(new Uri(uri));
        //    await SendEndpoint.Send(obj);
        //    //await BusControl.Publish(obj, context => { context.DestinationAddress = new Uri(uri); });
        //}
    }
}
